/*
 * @Author: “ygnnli” “1585923072@qq.com”
 * @Date: 2024-07-30 09:42:13
 * @LastEditors: “ygnnli” “1585923072@qq.com”
 * @LastEditTime: 2024-08-10 17:14:53
 * @FilePath: /110/30/named_pipe/Pipe_Client.cc
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include "Comm.hpp"

int main()
{
    int wfd = open(Path, O_WRONLY); //O_RDONLY 读，O_WRONLY 写，O_RDWR 读写
    if (wfd < 0)
    {
        cerr << "open failed, errno: " << errno << ", errstring: " << strerror(errno) << endl;
        return 1;
    }

    string inbuffer;
    while (true)
    {
        cout << "Please Enter Your Message# ";
        std::getline(cin, inbuffer);//获取一行输入
        if (inbuffer == "quit")
            break;
        ssize_t n = write(wfd, inbuffer.c_str(), inbuffer.size());
        if (n < 0)
        {
            cerr << "write failed, errno: " << errno << ", errstring: " << strerror(errno) << endl;
            break;
        }
    }

    return 0;
}